#pragma once
#ifndef IO_STREAMREADER_H
#define IO_STREAMREADER_H
//------------------------------------------------------------------------------
/**
    @class Core::StreamReader
    
    Stream reader classes provide a specialized read-interface for a stream. 
    This is the abstract base class for all stream readers. It is possible
    to attach any number of readers and writers to the same stream.
    
    (C) 2006 Radon Labs GmbH
*/

#include "stream.h"

//------------------------------------------------------------------------------
namespace GBase
{
	class StreamReader
	{
	public:
		/// constructor
		StreamReader();
		/// destructor
		virtual ~StreamReader();
		/// set stream to read from
		void SetStream(Stream* s, bool delStream);
		/// get currently set stream 
		Stream* GetStream();
		/// return true if a stream is set
		bool HasStream() const;
		/// return true if the stream has reached EOF
		bool Eof() const;
		/// begin reading from the stream
		virtual bool Open();
		/// end reading from the stream
		virtual void Close();
		/// return true if currently open
		bool IsOpen() const;
	protected:
		//Ptr<Stream> stream;
		Stream* stream;
		bool deleteStream;
		bool isOpen;
		bool streamWasOpen;
	};

	//------------------------------------------------------------------------------
	/**
	*/
	inline
	bool
	StreamReader::IsOpen() const
	{
		return this->isOpen;
	}

} // namespace Core
//------------------------------------------------------------------------------
#endif    